package com.woniu.serverdriveruser.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniu.internalcommon.dto.ApiBossCar;
import com.woniu.serverdriveruser.service.CarService;
import com.woniu.internalcommon.dto.Car;
import com.woniu.internalcommon.dto.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/car")
public class CarController {

    @Autowired
    private CarService carService;

    /**
     *  新增车辆
     * @param car
     * @return
     */
    @PostMapping("/addCar")
    public ResponseResult addCar(@RequestBody Car car){
        carService.add(car);
        return ResponseResult.success("添加成功");
    }
    /**
     *  查询车辆
     * @param id
     * @return
     */
    @GetMapping("/getCarById")
    public ResponseResult getCarById(@RequestParam("id") Long  id) {
        return  carService.selectById(id);
    }


    /**
     *  查询车辆--分页+条件
     * @param apiBossCar
     * @return
     */
    @PostMapping("/getAllCar")
    ResponseResult<Page<Car>> getAllCar(@RequestBody ApiBossCar apiBossCar){
       return carService.getAllCar(apiBossCar);
    }

}
